package face.pay.web.device.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import face.pay.dao.DeviceBatchInfoDao;
import face.pay.entity.DeviceBatchInfo;
import face.pay.entity.UserInfo;
import face.pay.util.page.PageData;
import face.pay.util.page.PageParam;
import face.pay.web.device.service.DeviceBatchInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Classname DeviceBatchInfoServiceImpl
 * @Description JJL
 * @Date 2019/11/12 12:06
 */
@Service
@Slf4j
public class DeviceBatchInfoServiceImpl implements DeviceBatchInfoService {

    @Autowired
    private DeviceBatchInfoDao deviceBatchInfoDao;

    @Override
    public PageData queryPage(UserInfo loginUser,PageParam pageParam, DeviceBatchInfo deviceBatchInfo) {

        PageHelper.startPage(pageParam.getPageNo(),pageParam.getPageSize());

        deviceBatchInfo.setOemId(loginUser.getOemId());

        List<DeviceBatchInfo> oemList = this.deviceBatchInfoDao.queryList(deviceBatchInfo);

        PageInfo<DeviceBatchInfo> pageInfo = new PageInfo <>(oemList);

        PageData<DeviceBatchInfo> pageData = new PageData<>(pageInfo.getTotal(),oemList);

        return pageData;
    }
}
